package Offer.offer;

import domain.TreeNode;

/**
 * 二叉树的镜像
 * @author leiwenkang
 * @date 2020/4/6
 */
public class Test19二叉树的镜像 {
    public void mirrorTree(TreeNode root) {
        if (root == null) {
            return;
        }
        //交换左右孩子
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;

        if (root.left != null) {
            mirrorTree(root.left);
        }

        if (root.right != null) {
            mirrorTree(root.right);
        }
    }
}
